package utils

import (
	"log"
	"os"
)

// 判断所给路径是否为文件夹
func IsDir(path string) bool {
	s, err := os.Stat(path)
	if err != nil {
		return false
	}
	return s.IsDir()
}

// 判断所给路径是否为文件
func IsFile(path string) bool {
	return !IsDir(path)
}

func Log(path string, data string, level int) {

	if level == 0 {
		log.Println(path, data)
	} else if level == 1 {
		log.Panic(path, data)
	} else if level == 2 {
		log.Fatal(path, data)
	}
}

func Put(dir string, path string, data string) {
	PathExists(dir)
	file, _ := os.OpenFile(dir+"/"+path, os.O_RDWR|os.O_CREATE, 0777)
	file.WriteString(data)
	file.Close()
}
